package ArrayList;

import java.util.ArrayList;

public class ArrayListDemo2 {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = new Student("哈哈哈", 20);
        Student s2 = new Student("范文芳", 23);
        Student s3 = new Student("嘎嘎发", 25);
        Student s4 = new Student("社会哥", 26);

        list.add(s1);
        list.add(s2);
        list.add(s3);
        list.add(s4);
        for (int i = 0; i < list.size(); i++) {
            Student stu = list.get(i);
            System.out.println("姓名："+stu.getName()+", 年龄："+stu.getAge());
        }

    }
}
